package com.gupaoedu.starter.autoconfiguration;

import com.gupaoedu.starter.format.FormatProcessor;
import com.gupaoedu.starter.format.JsonFormatProcessor;
import com.gupaoedu.starter.format.StringFormatProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * <p>
 *
 * </p>
 *
 * @author Nicky
 * @since 2019-07-13
 */
@Configuration
public class FormatConfiguration {

    @Bean
    @ConditionalOnMissingClass("com.alibaba.fastjson.JSON")
    @Primary
    public FormatProcessor stringFormatProcessor(){
        return  new StringFormatProcessor();
    }

    @Bean
    @ConditionalOnClass(name ="com.alibaba.fastjson.JSON")
    public FormatProcessor JsonFormatProcessor(){
        return new JsonFormatProcessor();
    }

}
